﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace HCQ2_Model.VRDD.InputDto._20220314
{
    /// <summary>
    ///  新增元宇宙素材商品信息
    /// </summary>
    public class AddMaterialParam
    {
        /// <summary>
        ///  登录用户userid
        /// </summary>
        [Required(ErrorMessage = "userid：用户id必传项！")]
        public string userid { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "fileName：名称必传项！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>     
        public string fileNote { get; set; }
        /// <summary>
        ///  所属目录id
        /// </summary>
        [Required(ErrorMessage = "folderID：所属目录id必传项！")]
        public int folderID { get; set; }
        /// <summary>
        ///  在文件服务器保存的文件ID
        /// </summary>
        [Required(ErrorMessage = "attachID：服务器id必传项！")]
        public int attachID { get; set; }
        /// <summary>
        ///  文件大小【单位：Kb】
        /// </summary>
        [Required(ErrorMessage = "fileSize：文件大小必传项！")]
        public decimal fileSize { get; set; }
        /// <summary>
        ///  价格明细
        /// </summary>
        [Required(ErrorMessage = "listPrice：价格明细必传项！")]
        public List<PriceListModel> listPrice { get; set; }
        /// <summary>
        ///  转实体模型
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfo toEntry()
        {
            return new T_DocumentInfo
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                file_size = this.fileSize,
                programId = this.attachID,
                page_type = "QDMaterial",
                isEntity = false,
                file_status = 1,
                create_time = DateTime.Now,
                update_time = DateTime.Now,
                pro_type = 6,
                file_classify = "",
                doc_type = ""
            };
        }
        /// <summary>
        ///  验证int必填项
        /// </summary>
        /// <returns></returns>
        public string verifyData()
        {
            string msg = string.Empty;
            if (folderID <= 0)
                msg = "目录导航数id必传项！";
            if (attachID <= 0)
                msg = "文件服务器id必传项！";
            if (fileSize <= 0)
                msg = "文件大小必传项！";
            if(listPrice==null || listPrice.Count<=0)
                msg = "价格明细必传项！";
            return msg;
        }
    }
    /// <summary>
    ///  价格明细
    /// </summary>
    public class PriceListModel
    {
        /// <summary>
        ///  月份
        /// </summary>
        [Required(ErrorMessage = "month：月份必传项！")]
        public int month { get; set; }
        /// <summary>
        ///  价格
        /// </summary>
        [Required(ErrorMessage = "price：价格必传项！")]
        public decimal price { get; set; }
    }
    /// <summary>
    ///  编辑素材商品信息
    /// </summary>
    public class EditMaterialParam
    {
        /// <summary>
        ///  商品ID
        /// </summary>
        [Required(ErrorMessage = "fileID：商品ID必传项！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请输入商品ID")]//大于0正则表达式
        public int fileID { get; set; }
        /// <summary>
        ///  素材缩略图在文件服务器的访问地址
        /// </summary>
        [Required(ErrorMessage = "imageUrl：必传项！")]
        public string imageUrl { get; set; }
        /// <summary>
        ///  登录用户userid
        /// </summary>
        [Required(ErrorMessage = "userid：用户id必传项！")]
        public string userid { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "fileName：名称必传项！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>     
        public string fileNote { get; set; }
        /// <summary>
        ///  所属目录id
        /// </summary>
        [Required(ErrorMessage = "folderID：所属目录id必传项！")]
        public int folderID { get; set; }
        /// <summary>
        ///  价格明细
        /// </summary>
        [Required(ErrorMessage = "listPrice：价格明细必传项！")]
        public List<PriceListModel> listPrice { get; set; }
        /// <summary>
        ///  验证int必填项
        /// </summary>
        /// <returns></returns>
        public string verifyData()
        {
            string msg = string.Empty;
            if (folderID <= 0)
                msg = "目录导航数id必传项！";
            if (listPrice == null || listPrice.Count <= 0)
                msg = "价格明细必传项！";
            return msg;
        }
    }
}